﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Text;
using System.Threading;

namespace PoshRabbit
{
    [Cmdlet( VerbsLifecycle.Start, "RabbitConsumer")]
    public class StartConsumerCmdlet : Cmdlet
    {
        [Parameter(ValueFromPipeline = true, Mandatory = true)]
        public IRabbitConsumer Consumer { get; set; }

        RabbitConsumer RabbitConsumer
        {
            get { return (PoshRabbit.RabbitConsumer) Consumer; }
        }

        protected override void ProcessRecord()
        {
            ThreadPool.QueueUserWorkItem(c => RabbitConsumer.Start());
        }
    }
}
